package com.yhn.bubblevideo.common.model;


import com.yhn.bubblevideo.common.enums.IErrorCode;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 通用返回类
 *
 * @param <T>
 * @author yhnyhn123
 */
@Data
@NoArgsConstructor
public class BaseResponse<T> implements Serializable {

    private String code;

    private T data;

    private String message;

    public BaseResponse(String code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public BaseResponse(String code, T data) {
        this(code, data, "");
    }

    public BaseResponse(String msg) {
        this("500", null, msg);
    }

    public BaseResponse(IErrorCode errorCode) {
        this(errorCode.code(), null, errorCode.message());
    }
}
